package br.com.moove.bananasfit.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import br.com.moove.bananasfit.R;
import br.com.moove.bananasfit.model.IComprarFits;
import br.com.moove.bananasfit.model.PessoaFisica;

public class ComprarFitsActivity extends ActionBarActivity implements IComprarFits {

	private int FITS_REQUEST_CODE = 234;

	PessoaFisica usuario;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
		setContentView(R.layout.activity_compra_fits);

		usuario = (PessoaFisica) getIntent().getSerializableExtra("Usuario");

		ComprarFitsFragment b = ComprarFitsFragment.getInstance(usuario);
		getFragmentManager().beginTransaction()
				.replace(R.id.layoutComprarFits, b).commit();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.sobre, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}	




	@Override
	public void comprarFits(int qtdFits) {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		intent.putExtra("QtdFits", qtdFits);
		setResult(FITS_REQUEST_CODE, intent);
		finish();
	}

}
